radiobutton: don't consider hidden buttons in the group for focus
authorCosimo Cecchi <cosimo@endlessm.com>
Fri, 31 Oct 2014 00:02:45 +0000 (17:02 -0700)
committerCosimo Cecchi <cosimoc@gnome.org>
Sat, 1 Nov 2014 17:08:42 +0000 (10:08 -0700)
When a GtkRadioButton has no focus, it will accept it when there is no
other active button in its group.
If the active button in the group is hidden, for example because the UI
desires not to have a default option pre-selected, currently the focus
will not be accepted, which is not desired behavior.

This commit changes the code to only consider visible buttons in the
group when checking whether another button is active.

https://bugzilla.gnome.org/show_bug.cgi?id=739474

gtk/gtkradiobutton.c

index 4e98dd90a2079b6a3ab148ec41f882125f31439f..e13062a4dc1be809b58c3e7960d1a905c26e8cc0 100644 (file)
@@ -743,7 +743,8 @@ gtk_radio_button_focus (GtkWidget         *widget,
       tmp_slist = priv->group;
       while (tmp_slist)
        {
-         if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tmp_slist->data)))
+         if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tmp_slist->data)) &&
+             gtk_widget_get_visible (tmp_slist->data))
            selected_button = tmp_slist->data;
          tmp_slist = tmp_slist->next;
        }